<!-- JSP USED TO ADD CANDIDATES-->
<jsp:useBean id="Voter" class="com.ignou.mca.beans.VotersFormBean"
	scope="request" />
<HTML>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="theme/Master.css" type="text/css">
<TITLE>Registration</TITLE>
<script type="text/javascript">
function userFocus()
{
	document.fm.firstName.focus();
}

function emailValidation(elem){
	//alert("emailvalidation"+elem);
	var emailExp = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$/;
	if(elem.match(emailExp)){
		return true;
	}else{
		alert("You have entered invalid email id. Please check.");
		document.fm.email.value = "";
		document.fm.email.focus();
		return false;
	}
}
function isNumeric(elem){
	var alphaExp = /^[0-9]+$/;
	if(elem.match(alphaExp)){
		return true;
	}else{
		alert("Entered phone number is invalid");
		document.fm.phoneNumber.focus();
		document.fm.phoneNumber.value = "";
		return false;
		}
}

function checkMandatoryFields() {
	var firstName,lastName, add1,city, state, country, ph,pinCode,userName,password,rptPassword,securityAnswer,email;
	firstName = document.fm.firstName.value;
	lastName = document.fm.lastName.value;
	add1 = document.fm.address1.value;
	city = document.fm.address1.value;
	state = document.fm.state.value;
	country = document.fm.country.value;
	ph = document.fm.phoneNumber.value;
	pinCode = document.fm.pinCode.value;
	userName = document.fm.userName.value;
	password = document.fm.password.value;
	rptPassword = document.fm.repeatPassword.value;
	securityAnswer = document.fm.securityAnswer.value;
	email = document.fm.email.value;

	if (firstName.length < 1) {
		alert("You must enter first name");
		document.fm.firstName.focus();
		return false;
	} else if (lastName.length < 1) {
		alert("You must enter last name");
		document.fm.lastName.focus();
		return false;
	}else if (add1.length < 1) {
		alert("You must enter Address1");
		document.fm.address1.focus();
		return false;
	}else if (city.length < 1) {
		alert("You must enter City");
		document.fm.city.focus();
		return false;
	} else if (state.length < 1) {
		alert("You must enter State");
		document.fm.state.focus();
		return false;
	} else if (country.length < 1) {
		alert("You must enter Country");
		document.fm.country.focus();
		return false;
	} else if (ph.length < 1) {
		alert("You must enter Phone Number");
		document.fm.phoneNumber.focus();
		return false;
	}else if (pinCode.length < 1) {
		alert("You must enter pincode");
		document.fm.pinCode.focus();
		return false;
	} else if (userName.length < 1) {
		alert("You must enter user name");
		document.fm.userName.focus();
		return false;
	} else if (password.length < 1) {
		alert("You must enter password");
		document.fm.password.focus();
		return false;
	} else if (rptPassword.length < 1) {
		alert("You must enter confirm password");
		document.fm.repeatPassword.focus();
		return false;
	}else if( password!=rptPassword)
	{
		alert("Invalid Password entered");
		document.fm.password.value="";
		document.fm.repeatPassword.value="";
		document.fm.password.focus();
		return false;
	}
	else if (securityAnswer.length < 1) {
		alert("You must enter Security code");
		document.fm.securityAnswer.focus();
		return false;
	} else if (email.length < 1) {
		alert("You must enter email");
		document.fm.email.focus();
		return false;
	} else if(ph.length >1)
	{
		return isNumeric(ph);
	}
	else if(email.length>1)
	{
		return emailValidation(email);
	}

	return true;
}
</script>
</HEAD>
<BODY onload="return userFocus()">
<table width="100%" border="0" cellpadding="0" cellspacing="0"
	bgcolor="#FFFFFF">
	<tr>
		<td height="21" bgcolor="#495e83"></td>
		<td height="21" bgcolor="#495e83"></td>
	</tr>
	<tr>
		<td height="119" align="left" valign="middle" bgcolor="#FFFFFF">
		<img alt="" src="././images/company_logo.JPG" width="304" height="53">
		</td>
		<td align="right" width="287"><img alt=""
			src="images/header_graphic.jpg" width="287" height="119"></td>
	</tr>
	<tr>
		<td height="45" width="100%" valign="middle" bgcolor="#495e83">
		&nbsp; &nbsp; &nbsp; <a href="Home.htm" class="links" target="">Home</a>
		&nbsp; &nbsp; &nbsp;<a href="Login.jsp" class="links" target="">Login</a>
		</td>

		<td bgcolor="#495e83"></td>
	</tr>
	<tr>
		<td height="1"><img alt="" src="images/spacer.gif" width="1"
			height="1"></td>
		<td height="1"><img alt="" src="images/spacer.gif" width="1"
			height="1"></td>
	</tr>
	<tr background="images/links_bot_fill.gif">
		<td height="30">&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="5"
	align="center">
	<tr>
		<td bgcolor="#FFFFFF" width="20"><img alt=""
			src="images/spacer.gif" width="20" height="10"></td>
		<td bgcolor="#FFFFFF" align="left" valign="top" class="text"
			height="309" width="99%"><br>
		<!-- #BeginEditable "content" -->
		<p class="title" align="center">Registration</p>
		<BR>
		<FORM action="UserRegistration" name="fm" method="post" onsubmit="return checkMandatoryFields()">
		<DIV align="left">
		<TABLE border="0" width="80" height="10" cellspacing="0"
			align="center" cellpadding="10">
			<TBODY>
				<TR>
					<TD nowrap width="30%">First Name:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="firstName"
						value='<%=Voter.getFirstName()%>' size="20"></TD>
					<TD nowrap width="30%">Last Name:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="lastName"
						value='<%=Voter.getLastName()%>' size="20"></TD>
				</TR>
				<TR>
					<TD nowrap width="30%">Address 1:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="address1"
						value="<%=Voter.getAddress1()%>" size="20"></TD>

					<TD nowrap width="30%">Address 2:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="address2"
						value="<%=Voter.getAddress2()%>" size="20"></TD>
				</TR>
				<TR>
					<TD nowrap width="30%">City:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="city"
						value="<%=Voter.getCity()%>" size="20"></TD>
				
					<TD width="51">State:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="text" name="state"
						value='<%=Voter.getState()%>' size="20"></TD>
				</TR>
				<TR>
					<TD width="51">Country:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="text" name="country"
						value='<%=Voter.getCountry()%>' size="20"></TD>
					<TD width="51">Pin code:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="text" name="pinCode"
						value='<%=Voter.getPinCode()%>' size="20"></TD>
				</TR>
				<TR>
					<TD width="51">Phone Number:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="text" name="phoneNumber"
						value='<%=Voter.getPhonenumber()%>' size="20"></TD>

					<TD width="51">Email:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="text" name="email"
						value='<%=Voter.getEmail()%>' size="20"></TD>
				</TR>
				<TR>
				<td>User Credentials</td>
				</TR>
				<TR>
					<TD width="51">User Name:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="text" name="userName"
						value='<%=Voter.getUserName()%>' size="20"></TD>
				</TR>
				<TR>
					<TD width="51">Password:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="password" name="password"
						value='<%=Voter.getPassword()%>' size="20"></TD>

					<TD width="51">Confirm Password:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="password" name="repeatPassword"
						value='<%=Voter.getRepeatPassword()%>' size="20"></TD>
				</TR>
				<TR>
					<TD width="51">Security Question:</TD>
					<TD width="36"></TD>
					<TD width="36"><select name="securityQuestion">
						<option>Who is your Childhood hero?</option>
						<option>Where did you born?</option>
						<option>In what city or town was your first job?</option>
						<option>What is your first phone number?</option>
						<option>What is your favorite car?</option>
						<option>What is your mother's middle name?</option>
						<option>What is your childhood nickname?</option>
						<option>What is your first school you studied?</option>
					</select>
					<TD width="51">Security Answer:</TD>
					<TD width="36"></TD>
					<TD width="36"><INPUT type="password" name="securityAnswer"
						value='<%=Voter.getSecurityAnswer()%>' size="20"></TD>
				</TR>

			</TBODY>
		</TABLE>
		<BR>
		</DIV>
		<DIV align="center"><INPUT type="reset" value="Clear"> <INPUT
			type="submit" name="Submit" value="Submit"></DIV>
		</FORM>
		<CENTER><jsp:useBean id="Message"
			class="com.ignou.mca.beans.Message" scope="session">
		</jsp:useBean> <jsp:getProperty name="Message" property="message" /> </CENTER>
	</tr>
	<tr>
		<td bgcolor="#495e83" width="20">&nbsp;</td>
		<td height="35" align="center" valign="middle" bgcolor="#495e83"
			class="footer">Copyright &copy; 2011 All Rights Reserved.
		Designed by Pradeepthi S</td>
		<td bgcolor="#495e83" width="20">&nbsp;</td>

	</tr>

</table>
</BODY>
</HTML>
